<%-- 
    Document   : agregarMateria
    Created on : 08-14-2012, 11:14:04 PM
    Author     : Susy
--%>
<%@include file="/include/struts-tags.jsp" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <%@include file="/include/head.jsp" %>
    <script type="text/javascript" src="js/funciones-reunion.js"></script>
    <script type="text/javascript">
      function cargarCarreras(){
        var form = document.getElementById("materiaForm");
        form.cmd.value = "searchMateria";
        form.submit();
    }
    
    function buscarMaterias(){
        var form = document.getElementById("materiaForm");
        form.cmd.value = "searchMaterias";
        form.submit();
    }
    
    function cargarMaterias(){
        var form = document.getElementById("materiaForm");
        form.cmd.value = "searchMateria";
        form.submit();
    }
    
    function deshabilitar(codigo){
            var campos = codigo.split("|"); 
            //var url = getBaseURL();
            var url = "";
            var form = document.getElementById("materiaForm");
            if(campos[2]=='A'){
                if(!confirm("Seguro que desea Deshabilitar esta materia?")){
                    return;
                }
                //url = url + "Materia.jsa?cmd=InhabilitarMateria&cod="+campos[0];
                url = "./Materia.jsa?cmd=InhabilitarMateria&cod="+campos[0];
            }else{
               if(!confirm("Seguro que desea Habilitar esta materia?")){
                    return;
                }
                //url = url + "Materia.jsa?cmd=HabilitarMateria&cod="+campos[0];
                url = "./Materia.jsa?cmd=HabilitarMateria&cod="+campos[0];
            }
            form.action = url;
            form.submit();
        }
        
        function refresh(){
            var form = opener.document.getElementById("becarioForm");
            form.cmd.value = "refresh";
            form.submit();
        }
    </script>
    <body onunload="refresh();">
        <br />
        <html:form action="/Materia" styleId="materiaForm">
            <html:hidden property="cmd" value="guardarMateria" />
            <table class="form">
                <caption class="titleSeg">agregar Materia</caption>
                <tr class="campos">
                    <td class="label">Activo:&nbsp;&nbsp;</td>
                    <td class="control" colspan="4"><html:checkbox property="estado" styleClass="check" /></td>
                </tr>
                <tr class="campos">
                    <td class="label">C&oacute;digo Materia:&nbsp;&nbsp;</td>
                    <td class="control"><html:text property="codigo" styleClass="tinput50"/></td>
                </tr>
                <tr class="campos">
                    <td class="label">Nombre Materia:&nbsp;&nbsp;</td>
                    <td class="control"><html:text property="nombre" styleClass="tinput200"/></td>
                    <td width="20px"></td>
                    <td class="label">UV:&nbsp;&nbsp;</td>
                    <td class="control"><html:select property="uv" styleClass="tinput50">
                            <html:option value="">-----</html:option>
                            <html:option value="1">  1 </html:option>
                            <html:option value="2">  2  </html:option>
                            <html:option value="3">  3 </html:option>
                            <html:option value="4">  4  </html:option>
                            <html:option value="5">  5 </html:option>
                        </html:select>
                    </td>
                </tr>
                <tr class="campos">
                    <td class="label">Universidad:&nbsp;&nbsp;</td>
                     <td class="control">
                        <html:select property="idUniv" styleClass="tinput178" onchange="cargarCarreras();">
                            <html:option value="">---Seleccione---</html:option>
                            <html:options collection="UniversidadesList" property="idUniv"
                                        labelProperty="nombre" labelName="nombre" ></html:options>
                        </html:select>
                    </td>
                    <td width="20px"></td>
                    <td class="label"> Carreras:&nbsp;&nbsp;</td>
                    <td class="control">
                        <html:select property="codCarrera" styleClass="tinput178" onchange="cargarMaterias();">
                            <html:option value="">---Seleccione---</html:option>
                            <html:options collection="CarrerasList" property="id.codCarrera"
                                        labelProperty="carrera" labelName="carrera" ></html:options>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center">
                        <html:submit value="Agregar" styleClass="button" />
                        <html:button property="search" value="Buscar" styleClass="button" onclick="buscarMaterias();"/>
                    </td>
                </tr>
                <logic:present name="msg">
                    <tr>
                        <td class="success" colspan="5">
                            <html:img src="./images/ok.png" />&nbsp;
                            <html:messages id="mensaje" name="msg">
                                <bean:write name="mensaje" />
                            </html:messages>
                        </td>
                    </tr>
                </logic:present>
                <logic:present name="errors">
                    <tr>
                        <td class="errors" colspan="5">
                            <html:img src="./images/error.png" />&nbsp;<html:errors name="errors" />
                        </td>
                    </tr>
                </logic:present>
            </table>
        </html:form>
        <br /><br />
        <logic:present name="MateriasList" scope="request">
            <display:table pagesize="10" name="MateriasList" requestURI="" class="results" style="width:90%;" id="results">
                <display:column property="materia" title="Acción" decorator="com.uca.sisbec.decorators.MateriaDecorator" sortable="true" />
                <display:column property="codMateria" title="Codigo Materia" sortable="true" />
                <display:column property="nombre" title="Nombre Materia" sortable="true" />
            </display:table>
        </logic:present>
        <script>
            var table = document.getElementById("results");
            var rows = table.getElementsByTagName("tr");
            for (var i = 1; i < rows.length; i++) {
                rows[i].onmouseover = function() {
                    this.className += ' hilite';
                }
                rows[i].onmouseout = function() {
                    this.className = this.className.replace(' hilite', '');
                }
            }
        </script>
    </body>
</html>
